package com.tencent.mm.opensdk.modelbiz;

import android.os.Bundle;
import android.util.Log;

import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONStringer;
import org.json.JSONTokener;

public class AddCardToWXCardPackage {
    public class Req extends BaseReq {
        public List cardArrary;

        public Req() {

        }

        public boolean checkArgs() {
            boolean v0_1;
            int v4 = 1024;
            if (this.cardArrary == null || this.cardArrary.size() == 0 || this.cardArrary.size() > 40) {
                v0_1 = false;
            } else {
                Iterator v2 = this.cardArrary.iterator();
                do {
                    if (v2.hasNext()) {
                        Object v0 = v2.next();
                        if (v0 != null && ((WXCardItem) v0).cardId != null && ((WXCardItem) v0).cardId.length() <= v4) {
                            if (((WXCardItem) v0).cardExtMsg == null) {
                                continue;
                            }

                            if (((WXCardItem) v0).cardExtMsg.length() <= v4) {
                                continue;
                            }
                        }

                        break;
                    } else {
                        return true;
                    }
                }
                while (true);
                v0_1 = false;
                return v0_1;
            }

            return v0_1;
        }

        public int getType() {
            return 9;
        }

        public void toBundle(Bundle arg6) {
            super.toBundle(arg6);
            JSONStringer v1 = new JSONStringer();
            try {
                v1.object();
                v1.key("card_list");
                v1.array();
                Iterator v2 = this.cardArrary.iterator();
                while (v2.hasNext()) {
                    Object v0_1 = v2.next();
                    v1.object();
                    v1.key("card_id");
                    v1.value(((WXCardItem) v0_1).cardId);
                    v1.key("card_ext");
                    String v0_2 = ((WXCardItem) v0_1).cardExtMsg == null ? "" : ((WXCardItem) v0_1).cardExtMsg;
                    v1.value(v0_2);
                    v1.endObject();
                }

                v1.endArray();
                v1.endObject();
            } catch (Exception v0) {
                Log.e("MicroMsg.AddCardToWXCardPackage", "Req.toBundle exception:" + v0.getMessage());
            }

            arg6.putString("_wxapi_add_card_to_wx_card_list", v1.toString());
        }
    }

    public static class Resp extends BaseResp {
        public List cardArrary;

        public Resp() {

        }

        public Resp(Bundle arg1) {

            this.fromBundle(arg1);
        }

        public boolean checkArgs() {
            boolean v0 = this.cardArrary == null || this.cardArrary.size() == 0 ? false : true;
            return v0;
        }

        public void fromBundle(Bundle arg6) {
            super.fromBundle(arg6);
            if (this.cardArrary == null) {
                this.cardArrary = new LinkedList();
            }

            String v0 = arg6.getString("_wxapi_add_card_to_wx_card_list");
            if (v0 != null && v0.length() > 0) {
                try {
                    JSONArray v1 = ((JSONObject) new JSONTokener(v0).nextValue()).getJSONArray("card_list");
                    int v0_2;
                    for (v0_2 = 0; v0_2 < v1.length(); ++v0_2) {
                        JSONObject v2 = v1.getJSONObject(v0_2);
                        WXCardItem v3 = new WXCardItem();
                        v3.cardId = v2.optString("card_id");
                        v3.cardExtMsg = v2.optString("card_ext");
                        v3.cardState = v2.optInt("is_succ");
                        this.cardArrary.add(v3);
                    }
                } catch (Exception v0_1) {
                }
            }
        }

        public int getType() {
            return 9;
        }

        public void toBundle(Bundle arg6) {
            super.toBundle(arg6);
            JSONStringer v2 = new JSONStringer();
            try {
                v2.object();
                v2.key("card_list");
                v2.array();
                Iterator v3 = this.cardArrary.iterator();
                while (v3.hasNext()) {
                    Object v0_1 = v3.next();
                    v2.object();
                    v2.key("card_id");
                    v2.value(((WXCardItem) v0_1).cardId);
                    v2.key("card_ext");
                    String v1 = ((WXCardItem) v0_1).cardExtMsg == null ? "" : ((WXCardItem) v0_1).cardExtMsg;
                    v2.value(v1);
                    v2.key("is_succ");
                    v2.value(((long) ((WXCardItem) v0_1).cardState));
                    v2.endObject();
                }

                v2.endArray();
                v2.endObject();
            } catch (Exception v0) {
                Log.e("MicroMsg.AddCardToWXCardPackage", "Resp.toBundle exception:" + v0.getMessage());
            }

            arg6.putString("_wxapi_add_card_to_wx_card_list", v2.toString());
        }
    }

    public static final class WXCardItem {
        public String cardExtMsg;
        public String cardId;
        public int cardState;

        public WXCardItem() {

        }
    }

    private static final String TAG = "MicroMsg.AddCardToWXCardPackage";

    public AddCardToWXCardPackage() {

    }
}

